package com.thesis.student.controller;

import com.alibaba.fastjson.JSONObject;
import com.thesis.manage.common.utils.Result;
import com.thesis.manage.domain.Student;
import com.thesis.manage.service.LoginRegisterService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author php
 * @date 2018/3/31
 */
@RequestMapping("/user")
@RestController
public class UserController extends BaseController {

    @Resource
    private LoginRegisterService loginRegisterService;

    /**
     * 修改密码
     */
    @PostMapping("/password/update")
    public Map<String, Object> updatePassword(String password) {
        return buildMessage(() -> {
            Result result = getUser();
            Student student = JSONObject.parseObject(result.getData().toString(), Student.class);
            loginRegisterService.updatePassword(student.getId(), password);
            return null;
        });
    }
}
